﻿using System.Linq;
using UniMana.Utils.Controls;

namespace UniMana.Data
{
    public class Catalogue_ContractTypeInfo
    {
        #region /*Không thay đổi*/
        public bds m_bds = new bds();
        public void Save()
        {
            m_data.m_DCSave.SubmitChanges();
        }
        public void Delete()
        {
            m_bds.DeleteCurrent();
        }
        #endregion /*Không thay đổi*/
        private DBMain m_data = new DBMain();
        #region [Properties - Thuộc tính]
        public Catalogue_ContractType Properties
        {
            get { return m_bds.Current as Catalogue_ContractType; }
        }
        #endregion
        public Catalogue_ContractTypeInfo(int DefaultKey = 0)
        {
            var IQuery = m_data.m_DCSave.Catalogue_ContractTypes.Where(tb => tb.Catalogue_ContractTypeKey == DefaultKey);
            m_bds.DataSource = IQuery;
            var Row = IQuery.FirstOrDefault();
            if (Row == null)
            {
                Row = new Catalogue_ContractType();
                m_bds.Add(Row);
            }
        }
    }
}